package com.xing.action;

import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.xing.model.UserInfo;
import com.xing.service.LoginService;

@Controller
public class LoginAction extends BaseAction {
	/** */
	/**
     * 
     */
	private static final long serialVersionUID = 1L;

	private String userId;
	private String password;

	/**//*
		 * ����ͨ��Spring��IOC����ע��LoginService���Ӷ������֮���������ϵ
		 */
	@Resource
	private LoginService loginService;

	public void setLoginService(LoginService loginService) {
		this.loginService = loginService;
	}


	public String getUserId() {
		return userId;
	}


	public void setUserId(String userId) {
		this.userId = userId;
	}


	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}


	@Override
	public String execute() throws Exception {

		UserInfo userInfo = loginService.getUser(userId, password);
		if (userInfo != null) {
			
			Map<String, Object> session = getSession();
			session.put("user", userInfo);
			
			return SUCCESS;
		} else {
			return INPUT;
		}
	}


	@Override
	public String dataGrid() {
		return null;
	}
}
